home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok24.lha
/
TurboFiles
/
SpeedCheck.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
3KB
|
119 lines
(**********************************************************************
:Program. SpeedCheck.mod
:Contents. Compares the speed of Dos, AM-FileSystem and TurboFiles.
:Author. Stefan Salewski
:Copyright. Public Domain
:Language. Modula-2
:Translator. M2Amiga AMSoft V3.2d
:History. V1.0 1.Jul.1989
:Address. Stolper Weg 3, D-2160 Stade
**********************************************************************)
MODULE SpeedCheck;
(* This is only a simpel testprogram. I write it down in less than
one hour, so please don't look at this code
*)
FROM InOut IMPORT WriteString,WriteInt,WriteLn,Write,ReadLongInt,ReadString;
FROM RealInOut IMPORT WriteReal;
FROM Timer2 IMPORT StartTime,StopTime;
FROM Timer IMPORT TimeVal;
FROM SYSTEM IMPORT ADR;
IMPORT FileSystem;
IMPORT TurboFiles;
IMPORT Dos;
CONST
Runnings=7;
PROCEDURE WriteTime(t:TimeVal);
VAR
time:REAL;
BEGIN
time:=REAL(t.secs)+REAL(t.micro)*1.0E-6;
WriteReal(time,12,3);
END WriteTime;
VAR
amFile:FileSystem.File;
turboFile:TurboFiles.FilePtr;
l,bufferSize:LONGINT;
fileName:ARRAY[0..80] OF CHAR;
t:TimeVal;
fPtr:Dos.FileHandlePtr;
buffer:ARRAY[0..10240] OF CHAR;
i:INTEGER;
blockSize:ARRAY[1..Runnings] OF LONGINT;
BEGIN
blockSize[1]:=1;
blockSize[2]:=4;
blockSize[3]:=16;
blockSize[4]:=64;
blockSize[5]:=256;
blockSize[6]:=480;
blockSize[7]:=720;
WriteString('Test of the Speed of the Procedures');WriteLn;
WriteString('Dos.Read, FileSystem.ReadBytes, ');
WriteString('TurboFiles.ReadBytes and TurboFiles.TurboRead');
WriteLn;
WriteString('Name of the file to read: ');
ReadString(fileName);WriteLn;
WriteString('Buffersize for FileSystem and TurboFiles: (0-10240): ');
ReadLongInt(bufferSize);
WriteString('BlockSize Dos:Read FS:ReadBytes TF:ReadBytes TF:TurboRead');
WriteLn;
IF (bufferSize<=10240) AND (bufferSize>=0) THEN
FOR i:=1 TO Runnings DO
WriteLn;
WriteInt(blockSize[i],4);WriteString(' ');
StartTime();
fPtr:=Dos.Open(ADR(fileName),Dos.readWrite);
IF fPtr#NIL THEN
REPEAT
l:=Dos.Read(fPtr,ADR(buffer),blockSize[i])
UNTIL l=0;
Dos.Close(fPtr);
StopTime(t);
WriteTime(t);
END;
StartTime();
FileSystem.Lookup(amFile,fileName,bufferSize,FALSE);
IF amFile.res=FileSystem.done THEN
REPEAT
FileSystem.ReadBytes(amFile,ADR(buffer),blockSize[i],l)
UNTIL l=0;
FileSystem.Close(amFile);
StopTime(t);
WriteTime(t);
END;
StartTime();
IF TurboFiles.Lookup(turboFile,fileName,bufferSize,TurboFiles.ReadOnly)
=TurboFiles.done THEN
REPEAT
TurboFiles.ReadBytes(turboFile,ADR(buffer),blockSize[i],l)
UNTIL turboFile^.res#TurboFiles.done;
TurboFiles.CloseFile(turboFile);
StopTime(t);
WriteTime(t);
END;
StartTime();
IF TurboFiles.Lookup(turboFile,fileName,bufferSize,TurboFiles.ReadOnly)
=TurboFiles.done THEN
REPEAT
TurboFiles.TurboRead(turboFile,ADR(buffer),blockSize[i],l)
UNTIL turboFile^.res#TurboFiles.done;
TurboFiles.CloseFile(turboFile);
StopTime(t);
WriteTime(t);
END;
END;
WriteLn;WriteLn;
WriteString('Click CloseGadget to Exit');WriteLn;
END;
END SpeedCheck.